{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "65ff98b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "def mod(a, b):\n",
    "    remainder = a % b\n",
    "    if remainder < 0:\n",
    "        # Adjust remainder to ensure non-negative\n",
    "        remainder += abs(b)\n",
    "    return remainder\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "60048824",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "17 mod 5 = 2\n",
      "25 mod 7 = 4\n",
      "69 mod 23 = 0\n"
     ]
    }
   ],
   "source": [
    "a = 17\n",
    "b = 5\n",
    "remainder = mod(a, b)\n",
    "print(f'{a} mod {b} = {remainder}')\n",
    "# 17 mod 5 = 2\n",
    "\n",
    "a = 25\n",
    "b = 7\n",
    "remainder = mod(a, b)\n",
    "print(f'{a} mod {b} = {remainder}')\n",
    "# 25 mod 7 = 4\n",
    "\n",
    "a = 69\n",
    "b = 23\n",
    "remainder = mod(a, b)\n",
    "print(f'{a} mod {b} = {remainder}')\n",
    "# 69 mod 23 = 0\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
